.PHONY: all,clean

BIN_FILE := hello
all : $(BIN_FILE)

obj_dir      := obj
$(shell mkdir -p $(obj_dir))
$(shell $(CPP) -P hello.lds.S -o hello.lds)

headers := $(wildcard *.h)

#hello
hello_source := $(wildcard hello_*.c)
hello_obj    := $(patsubst %.c, $(obj_dir)/%.o, $(hello_source))
hello : $(hello_obj)
	ld -T hello.lds $^ -o $@ -lc --dynamic-linker /lib64/ld-linux-x86-64.so.2

$(obj_dir)/%.o : %.c $(headers)
	$(CC) -g -c $< -o $@

clean :
	rm -f $(obj_dir)/*.o
	rm -f $(BIN_FILE)
